﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Milan.Deploy
{
	/// <summary>
	/// This checks periodically for a new download and then downloads it to the install directory.
	/// </summary>
	public class DownloadScanner : PeriodicScanner
	{
		public DownloadScanner(Application application)
			: base(application, 60 * 60)
		{

		}
		/// <summary>
		/// After the first check, how many minutes should we wait until the secondary checks.
		/// Default: Alpha = 5 minutes
		/// Default: Beta = 15 minutes
		/// Default: Official or latest = every day
		/// </summary>
		public const int DelayBetweenChecksMinutes = 5;
		public const int DelayBetweenChecksBetaMinutes = 15;
		public const int DelayBetweenChecksOfficialMinutes = 24 * 60;
		/// <summary>
		/// Grabs the latest version.
		/// </summary>
		protected override void RunOnce()
		{
			Client client = new Client();
			if (client.IsNewVersionAvailable())
			{
				client.DownloadLatest();
			}
		}
	}
}
